<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<!-- 

    People.prototype.constructor===p1.__proto__.constructor
 -->


    <script>
        function People()
        {
            this.name='turmp'
            this.age=70
        }
        People.prototype={
            constructor:People,   //强行指向了原构造函数
            buy:function()
            {
                console.log('这是buy方法');
            },
            vote:function()
            {
                console.log('这是vote方法');
            }
        };
        var p1=new People()
            p1.buy()
            p1.vote()
        console.log(p1);
        console.log(p1.constructor);


        function People2()
        {
            this.name='biden'
            this.age=76
        }
        People2.prototype.buy=function()  //给构造函数的原型对象 添加方法 共享  为了节省空间
        {
            console.log('这是people2的buy方法');
        }
        People2.prototype.vote=function()
        {
            console.log('这是people2的vote方法');

        }
        var p2=new People2()
        console.log(p2);
        console.log(p2.constructor);
        // console.log(p2.vote());
    </script>
    
</body>
</html>